/**
 * name: 游戏Tips控件
 * author: wyd
 * 写出一个控件方便扩展
 */
class TipsItem extends eui.Component{

    // private main_group:eui.Group;
    private lb_message:eui.Label;
    private data;

    /**
     * 所需参数
     * 1、str字符串
     */
    constructor(prama ?:any)
    {
        super();   
        this.data = prama;
		this.skinName = 'TipsItemSkin';
    }

    protected childrenCreated()
    {
       this.setUI();
    }

    protected setUI()
    {
        this.lb_message.text = this.data["str"];
        let lb_width = this.lb_message.width;

        // this.main_group.width = lb_width;
        // this.main_group.horizontalCenter = this.main_group.verticalCenter = 0;
    }

    public startAction()
    {
        this.alpha = 1;
        egret.Tween.removeTweens(this);
        egret.Tween.get(this).to({y:this.y - 200}, 500, egret.Ease.circOut).wait(500).call(()=>{
                egret.Tween.removeTweens(this);
                if(this.parent){
                    this.parent.removeChild(this);
                }
        });
    }

	public changeData(data:any)
    {
        this.data = data;
        this.setUI();
    }

    public destory()
    {
        this.data = null;
    }
}